/*
 ============================================================================
 Name		: ImageEncoder.h
 Author	  : Lenka Litvova
 Version	 : 1.0
 Copyright   : Copyright belongs to Lenka Litvova
 Description : CImageEncoder declaration
 ============================================================================
 */

#ifndef IMAGEENCODER_H
#define IMAGEENCODER_H

#include <e32base.h>	// For CActive, link against: euser.lib
#include <e32std.h>		// For RTimer, link against: euser.lib
#include <fbs.h>

class CImageEncoder;
class CFRamI_UIAppUi;

class CImageSaver : public CActive
	{
public:
	// Cancel and destroy
	~CImageSaver();

	// Two-phased constructor.
	static CImageSaver* NewL(CFRamI_UIAppUi *aAppUi);

	// Two-phased constructor.
	static CImageSaver* NewLC(CFRamI_UIAppUi *aAppUi);

public:
	// New functions
	// Function for making the initial request
	void SaveImage(const CFbsBitmap& aBitmap);
	void SaveImage(const CFbsBitmap* aBitmap);
	
private:
	// C++ constructor
	CImageSaver(CFRamI_UIAppUi *aAppUi);

	// Second-phase constructor
	void ConstructL();

	/**
	 * Function sets the automatic next file name.
	 */
	void GetNextUsableFileName();
private:
	// From CActive
	// Handle completion
	void RunL();

	// How to cancel me
	void DoCancel();

	// Override to handle leaves from RunL(). Default implementation causes
	// the active scheduler to panic.
	TInt RunError(TInt aError);

private:
	CImageEncoder* iEncoder;
	TFileName iNewFileName;
	HBufC* iImagePath;
	CFbsBitmap* iSaveBmp;
	RFs iFs;
	CFRamI_UIAppUi *iAppUi;
	};

#endif // IMAGEENCODER_H
